<?php
/**
 * <b>RUBIK IT Solution & Development ltd.</b>
 *
 * PROJECT		: Auction
 * @version 	: 1.1
 * COPYRIGHT    : 2010
 * ------------------------------------------------------
 *
 * Created on	:  Sep 13, 2010
 *
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );
RClassesImporter::cls('controllers.AbstractBackEndController');

/**
 * The controller for State application
 *
 */
class AlbumFrontController extends AbstractBackEndController {

	var $_model;

	function __construct() {
		parent::__construct();
		SysApplication::importModelCls('AlbumModel');
		$this->_model = new AlbumModel();
	}

	function display() {
		$lang = $_REQUEST['lang'];
		$root = SYS_ROOT_URL;
		$model = $this->_model;
		$listAlbum = $model->loadListAlbum();
		$albumItem = "";
		
		
		$photo = SysLanguage::_("PHOTO");
		$video = SysLanguage::_("VIDEO");
		$presentation = SysLanguage::_("PRESENTATION");
		
		
		foreach ($listAlbum as $item){
			$thumb = $item->image;
			$id = $item->id;
			$sql = "SELECT * FROM image WHERE 	album_id = '$id'";
			$result = SysDatabase::loadObjectList($sql);
			$count = count($result);
			if($_REQUEST['lang'] == 'fr'){
				$des = strip_tags($item->des_fr);
			} else if($_REQUEST['lang'] == 'en'){
				$des = strip_tags($item->des_en);
			}
			eval('$albumItem .= "'.SysApplication::loadTemplate('front/albumItem').'";');
		}
		eval('echo "'.SysApplication::loadTemplate('front/default').'";');
	}
	
	function albumDetails(){
		$id = SysRequest::getVar("task");
		$root = SYS_ROOT_URL;
		$lang = $_REQUEST['lang'];
		$model = $this->_model;
		$listImage = $model->loadImageByAlbum($id);
		$imageItem = "";
		if (empty($listImage)){
			$abc = '<div style="text-align:center">There is no item!</div>';	
		}else {
			foreach ($listImage as $item){
				$idImg = $item->img_id;
				$image = $item->img_link;
				if($_REQUEST['lang'] == 'fr'){
					$des = $item->img_des_fr;
				} else if($_REQUEST['lang'] == 'en'){
					$des = $item->img_des_en;
				}
				eval('$imageItem .= "'.SysApplication::loadTemplate('front/imageItem').'";');
			}
		}

		
		
		eval('echo "'.SysApplication::loadTemplate('front/listImage').'";');
	}
	
	

}
